<?php

/**
 * This is the model class for table "borrower_info".
 *
 * The followings are the available columns in table 'borrower_info':
 * @property string $borrower_id
 * @property string $borrower_firstname
 * @property string $borrower_middlename
 * @property string $borrower_lastname
 * @property string $borrower_religion
 * @property string $borrower_civil_status
 * @property string $borrower_date_of_birth
 * @property string $borrower_place_of_birth
 * @property string $borrower_citizenship
 * @property string $borrower_area_id
 * @property integer $borrower_status
 *
 * The followings are the available model relations:
 * @property BorrowerAddressInfo[] $borrowerAddressInfos
 */
class BorrowerInfo extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return BorrowerInfo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'borrower_info';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('borrower_firstname, borrower_middlename, borrower_lastname, borrower_area_id, borrower_status', 'required'),
			array('borrower_status', 'numerical', 'integerOnly'=>true),
			array('borrower_firstname, borrower_middlename, borrower_lastname, borrower_citizenship', 'length', 'max'=>50),
			array('borrower_religion', 'length', 'max'=>100),
			array('borrower_civil_status', 'length', 'max'=>45),
			array('borrower_place_of_birth', 'length', 'max'=>500),
			array('borrower_area_id', 'length', 'max'=>10),
			array('borrower_date_of_birth', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('borrower_id, borrower_firstname, borrower_middlename, borrower_lastname, borrower_religion, borrower_civil_status, borrower_date_of_birth, borrower_place_of_birth, borrower_citizenship, borrower_area_id, borrower_status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'borrowerAddressInfos' => array(self::HAS_MANY, 'BorrowerAddressInfo', 'borrower_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'borrower_id' => 'Borrower',
			'borrower_firstname' => 'Borrower Firstname',
			'borrower_middlename' => 'Borrower Middlename',
			'borrower_lastname' => 'Borrower Lastname',
			'borrower_religion' => 'Borrower Religion',
			'borrower_civil_status' => 'Borrower Civil Status',
			'borrower_date_of_birth' => 'Borrower Date Of Birth',
			'borrower_place_of_birth' => 'Borrower Place Of Birth',
			'borrower_citizenship' => 'Borrower Citizenship',
			'borrower_area_id' => 'Borrower Area',
			'borrower_status' => 'Borrower Status',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('borrower_id',$this->borrower_id,true);
		$criteria->compare('borrower_firstname',$this->borrower_firstname,true);
		$criteria->compare('borrower_middlename',$this->borrower_middlename,true);
		$criteria->compare('borrower_lastname',$this->borrower_lastname,true);
		$criteria->compare('borrower_religion',$this->borrower_religion,true);
		$criteria->compare('borrower_civil_status',$this->borrower_civil_status,true);
		$criteria->compare('borrower_date_of_birth',$this->borrower_date_of_birth,true);
		$criteria->compare('borrower_place_of_birth',$this->borrower_place_of_birth,true);
		$criteria->compare('borrower_citizenship',$this->borrower_citizenship,true);
		$criteria->compare('borrower_area_id',$this->borrower_area_id,true);
		$criteria->compare('borrower_status',$this->borrower_status);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}